<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>打印处方</title>
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="icon" type="image/png" href="/resources/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="/resources/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
    <script src="/resources/js/echarts.min.js"></script>
    <link rel="stylesheet" href="/resources/css/amazeui.min.css"/>
    <link rel="stylesheet" href="/resources/css/amazeui.min.css" media="print" />
    <link rel="stylesheet" href="/resources/css/amazeui.datatables.min.css"/>
    <script src="/resources/js/jquery.min.js"></script>

    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="http://cdn.bootcss.com/jquery/2.1.1/jquery.min.js"></script>
    <script src="http://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="/resources/jsutlis/DateFormat.js"></script>
    <style type="text/css">
        body input{border-bottom:0}
        body{
            background-color: #FFFFFF;
        }
    </style>
</head>

<body>
<script src="/resources/js/theme.js"></script>
<!--注意要加上html里star和end的这两个标记-->

<!--startprint-->
<div class="am-g">
    <div class="am-u-md-12 am-u-lg-12">
        <div class="am-u-md-2 am-u-lg-2" style="color: #fff;"><input type="hidden" id="illid" value="${illcase.illCaseId}"></div>
        <div class="am-u-md-8 am-u-lg-8">
            <div class="am-u-md-12" style="text-align: center; border-bottom: #000 1px solid;">
                <h4>天使落凡尘儿健康管理中心</h4>
                <h4>${branches}</h4>
                <h2>结算单</h2>
            </div>
            <div class="am-u-md-12 am-u-lg-12">
                <div class="am-u-md-4 am-u-lg-4">
                    <div class="am-u-md-12 am-u-lg-12">
                        <label>结算编号：</label>
                        <span>NO${illcase.illCaseNo}</span>
                    </div>
                    <div class="am-u-md-12 am-u-lg-12">
                        <label>姓名：</label>
                        <span>${baby.babyName}</span>
                    </div>
                    <div class="am-u-md-12 am-u-lg-12">
                        <label>电话：${userinfo.userTel}</label>
                        <span></span>
                    </div>
                </div>
                <div class="am-u-md-4 am-u-lg-4">
                    <div class="am-u-md-12 am-u-lg-12">
                        <label>会员卡号：</label>
                        <span>${vipinfo.vipNo}</span>
                    </div>
                    <div class="am-u-md-12 am-u-lg-12">
                        <label>会员卡名称：</label>
                        <span>${vipcard.vipName}</span>
                    </div>
                    <div class="am-u-md-12 am-u-lg-12">
                        <label>性别：</label>
                        <span><c:if test="${baby.babySex ==1}">男宝</c:if><c:if test="${baby.babySex ==0}">女宝</c:if></span>
                    </div>
                </div>
                <div class="am-u-md-4 am-u-lg-4">
                    <div class="am-u-md-12 am-u-lg-12">
                        <label style="color: #FFF;"></label>
                    </div>
                    <div class="am-u-md-12 am-u-lg-12">
                        <label>年龄：</label>
                        <span>${baby.babyAge}岁</span>
                    </div>
                </div>
            </div>
            <div class="am-u-md-12 am-u-lg-12" style="">
                <div class="am-u-md-12 am-u-lg-12" style="padding-left: 30px;">
                    <label>诊断结果：</label>
                    <span>${illcase.visit}</span>
                </div>
            </div>
            <div class="am-u-md-12 am-u-lg-12" style="border-bottom: #000 1px solid;">
                <div class="am-u-md-12 am-u-lg-12" style="padding-left: 30px;">
                    <label>注意事项：</label>
                    <span id="illCaseNotes"></span>
                </div>
            </div>
            <div class="am-u-md-12 am-u-lg-12" style="border-bottom: #000 1px solid; padding-bottom: 10px;">
                <div class="am-u-md-12 am-u-lg-12">
                    <h2>Rp</h2>
                    <div class="am-u-md-12 am-u-lg-12">
                        <h4 class="am-text-center">儿童餐和食品及产品类</h4>
                        <table width="100%" class=".am-table">
                            <thead>
                                <tr>
                                    <th class="am-text-center">名称</th>
                                    <th class="am-text-center">用量</th>
                                    <th class="am-text-center">价格 </th>
                                </tr>
                            </thead>
                            <tbody id="preDetils">
                              <%--  <tr>
                                    <td class="am-text-center">白菜</td>
                                    <td class="am-text-center">1g</td>
                                    <td class="am-text-center">100元 </td>
                                </tr>
                                <tr>
                                    <td class="am-text-center">白菜</td>
                                    <td class="am-text-center">1g</td>
                                </tr>
                                <tr>
                                    <td class="am-text-center">白菜</td>
                                    <td class="am-text-center">1g</td>
                                </tr>
                                <tr>
                                    <td class="am-text-center">白菜</td>
                                    <td class="am-text-center">1g</td>
                                </tr>
                                <tr>
                                    <td class="am-text-center">白菜</td>
                                    <td class="am-text-center">1g</td>
                                </tr>--%>
                            </tbody>
                        </table>
                    </div>
                    <div class="am-u-md-12 am-u-lg-12">
                        <h4 class="am-text-center">推拿、艾灸、贴服等</h4>
                        <table width="100%" class=".am-table">
                            <thead>
                            <tr>
                                <th class="am-text-center">名称</th>
                                <th class="am-text-center">用量</th>
                                <th class="am-text-center">价格 </th>
                            </tr>
                            </thead>
                            <tbody id="acupDetails">
                            <%--  <tr>
                                  <td class="am-text-center">白菜</td>
                                  <td class="am-text-center">1g</td>
                                  <td class="am-text-center">100元 </td>
                              </tr>
                              <tr>
                                  <td class="am-text-center">白菜</td>
                                  <td class="am-text-center">1g</td>
                              </tr>
                              <tr>
                                  <td class="am-text-center">白菜</td>
                                  <td class="am-text-center">1g</td>
                              </tr>
                              <tr>
                                  <td class="am-text-center">白菜</td>
                                  <td class="am-text-center">1g</td>
                              </tr>
                              <tr>
                                  <td class="am-text-center">白菜</td>
                                  <td class="am-text-center">1g</td>
                              </tr>--%>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            <div class="am-u-md-12 am-u-lg-12">
                <div class="am-u-md-12 am-u-lg-12">
                    <div class="am-u-md-4 am-u-lg-4">
                            <label>老师姓名:</label>
                            <span id="docName">呵呵哒</span>
                        </div>
                    <div class="am-u-md-4 am-u-lg-4">
                            <label>日期：</label>
                            <span id="currentdate">2018-08-20</span>
                        </div>
                    <div class="am-u-md-4 am-u-lg-4">
                            <label>金额：</label>
                            <span id="sumPrice"></span>
                        </div>
                </div>
            </div>

        </div>
        <div class="am-u-md-2 am-u-lg-2" style="color: #fff;"></div>
    </div>
</div>
<!--endprint-->

<div class="am-u-md-12 am-text-center"><button type="button" onclick="doPrint()">打印</button> <button type="button" onclick="updateState(${emId},'${emName}')">完成</button> </div>
<script type="text/javascript">

    var notice = "${illcase.illCaseNote}";
    if(notice != null && notice != "null" && notice != ""){
        $("#illCaseNotes").html(notice);
    }else{
        $("#illCaseNotes").html("无注意事项");
    }

$(function () {
    var illid = $('#illid').val();
    var formData = new FormData();
    console.log(illid);
    formData.append("illid",illid);
    url = '/illCaseController/getpre';
    $.ajax({
        url: url,
        type: 'POST',
        cache: false,
        data: formData,
        processData: false,
        contentType: false
    }).done(function (res) {
        if (res.success) {
            $('preDetils').empty();
            $('#docName').html(res.data.temId);
            if(res.data.reserve4 == "0" ){
                $("#sumPrice").html("该卡为体验卡，消费的是次数");
            }else {
                $("#sumPrice").html(res.data.reserve4);
            }
            $('#currentdate').html(formatDate(res.data.creatPresDate,'YY-MM-DD'));
            var detils = JSON.parse('['+res.data.presDetail+']');
            var s1 ='';
            var s2 ='';
            for (var i = 0;i<detils.length;i++){
              var tmp =  detils[i];
                    if (tmp.pretype == 'dietary'){
                        s1+='<tr><td class="am-text-center">'+tmp.prename+'</td><td class="am-text-center">'+tmp.precount+tmp.premeasure+'</td><td class="am-text-center">'+tmp.preprice+'元 </td></tr>';
                    }else {
                        s2+='<tr><td class="am-text-center">'+tmp.prename+'</td><td class="am-text-center">'+tmp.precount+tmp.premeasure+'</td><td class="am-text-center">'+tmp.preprice+'元 </td></tr>';
                    }
            }
            console.log(s1);
            $('#preDetils').append(s1);
            $('#acupDetails').append(s2);

        }else {
            alert(res.msg);
        }
    }).fail(function (res) {
        alert("网络错误");

        //  return res;
    });

});

    function doPrint() {
        bdhtml=window.document.body.innerHTML;
        sprnstr="<!--startprint-->";
        eprnstr="<!--endprint-->";
        prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17);
        prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));
        window.document.body.innerHTML=prnhtml;
        document.execCommand("print","true","true");
    }

    function updateState(emId,emName) {
        //匹配当前用户的emName
        var URL = "/process/updateIllCaseReserve";
        var formdata = new FormData();
        formdata.append("illCaseId",${illcase.illCaseId});
        switch (emName){
            case "nurse" :
                formdata.append("reserve11",emId);
                $.ajax({
                    url: URL,
                    type: 'POST',
                    cache: false,
                    data: formdata,
                    processData: false,
                    contentType: false
                }).done(function(res){
                    console.log(res.success);
                });
                break;
            case "cooker" :
                formdata.append("reserve12",emId);
                $.ajax({
                    url: URL,
                    type: 'POST',
                    cache: false,
                    data: formdata,
                    processData: false,
                    contentType: false
                }).done(function(res){
                    console.log(res.success);
                });
                break;
        }
    }
</script>
</body>
</html>